<template>
	<view class="coment">
		<view class="panel" v-for="(item,index) in dataList" :key="index">
			<view class="left">
				<image :src="item.userLogo== '' || item.userLogo== null?'../../static/images/user.png':item.userLogo " @error="setDetailUserLogo(item)" mode="scaleToFill"></image>
			</view>
			<view class="right">
				<view class="username">
					{{item.userName}}
				</view>
				<view class="sku">
					<text class="sku-left">
						{{item.productAttr}}
					</text>
					<text class="sku-right">
						{{item.gmtCreate}}
					</text>
				</view>
				<view class="user-com">
					{{item.comment}}
				</view>
				<!-- <view class="com-img">
					<video src="" controls></video>
					<image src="" mode=""></image>
					<image src="" mode=""></image>
					<image src="" mode=""></image>
				</view> -->
				<view class="merchant" v-if="item.list[0].comment">
					<text class="radio"></text>
					<view class="text">
						商家回复:
					</view>
					<view class="character">
						{{item.list[0].comment}}
					</view>
				</view>
			</view>
		</view>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				pageNum:1,
				id:"",
				dataList:[]
			}
		},
		onLoad(e) {
			this.id = e.id;
			this.getData()
		},
		onReachBottom() {
			this.getData()
		},
		methods: {
			getData(){
				let data = {
					pageNum:this.pageNum,
					"commentParentId": "",
					"pageSize": 10,
					"productId": this.id,
				}
				this.$http.post('/api/v1.0/product/comment/getComments',data,res=>{
					if(res.data.status == "000000"){
						this.dataList = this.dataList.concat(res.data.data.items);
						this.pageNum++
					}
				})
			},
			setDetailUserLogo(item){
				item.userLogo = '../../static/images/user.png'
			}
		}
	}
</script>

<style lang="scss" scoped>
	.coment {
		padding-top: 22upx;
		background: #FFFFFF;
	}

	.panel {
		display: flex;
		padding: 30upx;
		border-bottom: 1upx solid rgba(247,247,247,1);;
		.left>image {
			width: 36upx;
			height: 36upx;
			background: red;
			border-radius: 50%;
		}

		.right {
			margin-left: 10upx;

			.username {
				font-size: 26upx;
				font-weight: 500;
				line-height: 46upx;
				color: rgba(77, 77, 77, 1);
			}

			.sku {
				font-size: 22upx;
				font-weight: 500;
				line-height: 39upx;
				color: rgba(153, 153, 153, 1);

				.sku-right {
					margin-left: 20upx;
				}
			}

			.user-com {
				margin-top: 18upx;
				font-size: 28upx;
				font-weight: 500;
				line-height: 36upx;
				color: rgba(51, 51, 51, 1);
			}

			.com-img {
				padding: 10upx 0;
				display: flex;
				flex-direction: row;
				flex-wrap: wrap;
				justify-content: space-between;

				video {
					margin: 10upx 0;
					width: 200upx;
					height: 200upx;
					border-radius: 10px;
				}

				image {
					margin: 10upx 0;
					width: 200upx;
					height: 200upx;
					background: red;
					border-radius: 10px;
				}
			}

			.merchant {
				background:rgba(247,247,247,1);
				border-radius:10px;
				padding: 15upx 22upx 25upx;
				position: relative;  
				margin-top: 20upx;
				.radio{
					background:rgba(247,247,247,1);
					width: 20upx;
					height: 20upx;
					border-radius:50% ;
					position: absolute;
					top: -10upx;
				}
				.text {
					font-size: 24upx;
					font-weight: 500;
					line-height: 42upx;
					color: rgba(51, 51, 51, 1);
				}
				.character {
					padding-left: 20upx;
					font-size:22upx;
					font-weight:500;
					line-height:30upx;
					width: 500upx;
					color:rgba(128,128,128,1);
				}
			}
		}
	}
</style>
